@extends('project.common.framework') 
@section('content')
{{--  {{json_encode($api)}}  --}}
<div class="container-fluid api-content">
    <h2>{{ $api['title'] }}</h2>
    <p>最近更新时间：{{ $api['update_time'] }}</p>
    <h3>1. 接口地址</h3>
    <div class="markdown">{{ $api['url'] }}</div>

    <h3>2. 接口描述</h3>
    <div class="markdown">{{ $api['intro'] }}</div>

    <h3>3. 输入参数</h3>
    <p>以下请求参数列表仅列出了接口请求参数，正式调用时需要加上公共请求参数，见公共请求参数页面。</p>
    @if(!empty($api['inputs']))
    <div class="row">
        <table class="table col-lg-12 col-md-12 col-xs-12">
            <thead>
                <tr>
                    <th style="width:12%">参数名称</th>
                    <th style="width:12%">是否必选</th>
                    <th style="width:12%">类型</th>
                    <th style="width:64%">描述</th>	
                </tr>
            </thead>
            <tbody>
                @foreach ($api['inputs'] as $input)
                <tr>
                    <td>{{ $input['param'] }}</td>
                    <td>@if( $input['required'] == 1 ) 是 @else 否 @endif</td>
                    <td>{{ $input['type'] }}</td>
                    <td>{{ $input['description'] }}</td>
                </tr>  
                @endforeach
            </tbody>
        </table>
    </div>
    @endif

    <h3>4. 输出参数</h3>

    @if(!empty($api['outputs']))
    <div class="row">
        <table class="table col-lg-12 col-md-12 col-xs-12">
            <thead>
                <tr>
                    <th style="width:15%">参数名称</th>
                    <th style="width:15%">类型</th>
                    <th style="width:70%">描述</th>	
                </tr>
            </thead>
            <tbody>
                @foreach ($api['outputs'] as $output)
                <tr>
                    <td>{{ $output['param'] }}</td>
                    <td>{{ $output['type'] }}</td>
                    <td>{{ $output['description'] }}</td>
                </tr>  
                @endforeach
            </tbody>
        </table>
    </div>
    @endif

    @if(!empty($api['errors']) && $api['errors'] != '[]')
    <h3>5. 错误码</h3>
    <div class="row">
        <table class="table col-lg-12 col-md-12 col-xs-12">
            <thead>
                <tr>
                    <th style="width:30%">错误码</th>
                    <th style="width:70%">描述</th>	
                </tr>
            </thead>
            <tbody>
                @foreach ($api['errors'] as $error)
                <tr>
                    <td>{{ $error['code'] }}</td>
                    <td>{{ $error['description'] }}</td>
                </tr>  
                @endforeach
            </tbody>
        </table>
    </div>
    <h3>6. 示例</h3>
    @else
    <h3>5. 示例</h3>
    @endif
    <p>输入示例如下：</p>
    <div class="markdown">{{ $api['input_example'] }}</div>
    <p>返回示例如下：</p>
    <div class="markdown">{{ $api['output_example'] }}</div>
    @include('project.common.issue')
</div>
@endsection
@section('script')
<script src="{{ env('APP_STATIC') }}project/js/api.js"></script>
@endsection